
#ifndef VIDEODXGICAPTOR_H
#define VIDEODXGICAPTOR_H

#include <d3d11.h>
#include <dxgi1_2.h>

class VideoDXGICaptor
{
public:
    VideoDXGICaptor();
    ~VideoDXGICaptor();

public:
    BOOL Init();
    VOID Deinit();
	const int & getWidth() const { return m_iWidth; }
	const int & getHeight() const { return m_iHeight; }
	int getWidthBytes();

public:
    virtual BOOL CaptureImage(RECT &rect, void *pData, INT &nLen);
    virtual BOOL CaptureImage(void *pData, INT &nLen,INT &widthBytes);
    virtual BOOL ResetDevice();

private:
    BOOL  AttatchToThread(VOID);
    BOOL  QueryFrame(void *pImgData, INT &nImgSize);
	BOOL  QueryFrame(void *pImgData, INT &nImgSize, INT &widthBytes);

private:
    IDXGIResource *zhDesktopResource;
    DXGI_OUTDUPL_FRAME_INFO zFrameInfo;
    ID3D11Texture2D *zhAcquiredDesktopImage;
    IDXGISurface *zhStagingSurf;

private:
    BOOL m_bInit;
	int m_iWidth;
	int m_iHeight;
	int m_WidthBytes;

    ID3D11Device *m_hDevice;
    ID3D11DeviceContext *m_hContext;

    IDXGIOutputDuplication *m_hDeskDupl;
    DXGI_OUTPUT_DESC m_dxgiOutDesc;
};

#endif // VIDEODXGICAPTOR_H
